//
//  ActivityModel.m
//  豆瓣
//
//  Created by lanou3g on 15/12/10.
//  Copyright © 2015年 HaiTeng. All rights reserved.
//

#import "ActivityModel.h"


#define KTitle @"title"
#define KBegin_time @"begin_time"
#define KEnd_time @"end_time"
#define KAddress @"address"
#define KCategory_name @"category_name"
#define KParticipant_count @"participant_count"
#define KWisher_count @"wisher_count"
#define KImage @"image"
#define KName @"name"
#define KContent @"content"

@implementation ActivityModel

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
  
    
}

- (void)setValue:(id)value forKey:(NSString *)key
{
    
    [super setValue:value forKey:key];
    
    if ([key isEqualToString:@"owner"]) {
        _name = value[@"name"];
    }
}


//编码(存)
- (void)encodeWithCoder:(NSCoder *)aCoder
{


    [aCoder encodeObject:_title forKey:KTitle];
    [aCoder encodeObject:_begin_time forKey:KBegin_time];
    [aCoder encodeObject:_end_time forKey:KEnd_time];
    [aCoder encodeObject:_address forKey:KAddress];
    [aCoder encodeObject:_category_name forKey:KCategory_name];
    [aCoder encodeInt:_participant_count forKey:KParticipant_count];
    [aCoder encodeInt:_wisher_count forKey:KWisher_count];
    [aCoder encodeObject:_image forKey:KImage];
    [aCoder encodeObject:_name forKey:KName];
    [aCoder encodeObject:_content forKey:KContent];
}

//反编码(取)
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super init]) {

        
        _title = [aDecoder decodeObjectForKey:KTitle];
        _begin_time = [aDecoder decodeObjectForKey:KBegin_time];
        _end_time = [aDecoder decodeObjectForKey:KEnd_time];
        _address = [aDecoder decodeObjectForKey:KAddress];
        _category_name = [aDecoder decodeObjectForKey:KCategory_name];
        _participant_count = [aDecoder decodeIntForKey:KParticipant_count];
        _wisher_count = [aDecoder decodeIntForKey:KWisher_count];
        _image = [aDecoder decodeObjectForKey:KImage];
        _name = [aDecoder decodeObjectForKey:KName];
        _content = [aDecoder decodeObjectForKey:KContent];
        
    }
    return self;
}


@end
